package com.deuwise.system.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.deuwise.system.entity.AppDo;
import com.deuwise.system.service.AppDoService;
import com.deuwise.system.mapper.AppDoMapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * 应用 接口实现类
 *@author deuwise
 *@date 2018-11-20 10:36:29
 **/
@Service
public class AppDoServiceImpl extends ServiceImpl<AppDoMapper, AppDo> implements AppDoService {

    Logger logger= LoggerFactory.getLogger(AppDoServiceImpl.class);

    @Override
    public int queryByName(String name, AppDo appDo) {
        Wrapper<AppDo> appDoWrapper=new EntityWrapper<>();
        appDoWrapper.eq("name",name);
        if(appDo!=null){
            if(StringUtils.isNotBlank(appDo.getId())) {
                appDoWrapper.ne("id", appDo.getId());
            }
        }
        return baseMapper.selectCount(appDoWrapper);
    }

    @Override
    public int queryByCode(String code, AppDo appDo) {
        Wrapper<AppDo> appDoWrapper=new EntityWrapper<>();
        appDoWrapper.eq("code",code);
        if(appDo!=null){
            if(StringUtils.isNotBlank(appDo.getId())) {
                appDoWrapper.ne("id", appDo.getId());
            }
        }
        return baseMapper.selectCount(appDoWrapper);
    }

}